/* 
 * File:   dmm.h
 * Author: Chen Liu     Student Number:3996591
 *
 * Created on August 27, 2012, 2:27 PM
 */

#include <list>

typedef unsigned int WORD;
enum Policy{eFirstFit,eNextFit,eBestFit,eWorstFit};
const WORD USED=1;
const WORD FREE=0;

struct MemSeg
{
    WORD words;
    WORD *address;
};

class DMM
{
public:
    DMM(WORD *memory, int words, Policy type);
    char *New(int size);
    void Delete(char *address);
    void GetStats(int &bAlloc, int &blAlloc, int &Cmps);
private:
    Policy policy;
    WORD *startAddr;
    int capacity;
    std::list<MemSeg> freeSegList;    
    int bytesAlloc;
    int blockAlloc;
    int CmpsCounter;
    int Compare(WORD word1, WORD word2, int &counter);
    std::list<MemSeg>::iterator current;
    
};
